package com.qn.common.base.model;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;

import java.util.List;

/**
 * qingniu-cloud user source analysis
 *
 * @Author: TXG
 * @Date: 2024/6/11
 * @Version V0.0.2
 */
@Tag(name="分页数据返回封装")
public class ResponsePage<T> extends ResponseRows<T>{

    /***
     *
     * @param code 响应代码
     * @param message 响应消息
     * @param data 泛型实体对象
     * @param current 当前页码
     * @param total 总数据
     * @param size 每页数量
     */
    public  ResponsePage(Integer code, String message, List<T> data, Long current, Long total, Long size)
    {
        super(code,message,data);
        setCurrent(current);
        setTotal(total);
        setSize(size);
    }
    /***
     *
     * @param page 分页参数
     */
    public  ResponsePage(IPage<T> page)
    {
        super(ResponseCode.SUCCESS.code(),"成功",page.getRecords());
        setCurrent(page.getCurrent());
        setTotal(page.getTotal());
        setSize(page.getSize());
    }
    /**
     * 当前页码
     */
    private Long current;
    /**
    总数据量
     */
    private Long total;
    /**
    每页数量
     */
    private Long size;

    public Long getCurrent() {
        return current;
    }

    public void setCurrent(Long current) {
        this.current = current;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }
}
